package com.music.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.music.dao.MvMapper;
import com.music.entity.Mv;
import com.music.service.MvService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Classname MvServiceImpl
 * @Description TODO
 * @Version 1.0.0
 * @Date 2022/7/4 12:56
 * @Created by Administrator
 */
@Slf4j
@Service
@Transactional
public class MvServiceImpl implements MvService {

    @Autowired
    private MvMapper mvMapper;

    @Override
    public PageInfo<Mv> getMvByCondition(Integer pageNum, Integer pageSize, Integer districtId , Integer mvTypeId, String rank) {
        Map<String,Object> map = new HashMap<>();
        map.put("rank",rank);
        Mv mv = new Mv();
        mv.setDistrictId(districtId);
        mv.setMvTypeId(mvTypeId);
        map.put("mv",mv);
        PageHelper.startPage(pageNum,pageSize);
        List<Mv> mvList = mvMapper.selectBycondition(map);
        PageInfo<Mv> pageInfo = new PageInfo<>(mvList,5);
        return pageInfo;
    }

    @Override
    public Mv getMvByMvId(String mvId) {
        return mvMapper.selectByPrimaryKey(mvId);
    }

    @Override
    public List<Mv> getMvList(Integer districtId) {
        Map<String,Object> map = new HashMap<>();
        Mv mv = new Mv();
        mv.setDistrictId(districtId);
        map.put("mv",mv);
        List<Mv> mvList = mvMapper.selectBycondition(map);
        return mvList;
    }


}
